/*! \file
 * \brief Empty.
 * \author Ivo Wingelaar
 * \date 2011
 * \version 0.1.0
 * \copyright GNU Lesser General Public License v3
 */

#include "MythRandom_AlgorithmStub_C.hpp"

namespace Myth
{
namespace Random
{

/** default destructor **/
AlgorithmStub_C::~AlgorithmStub_C(void)
{
    //
}

/** virtual function **/
/** random_init      **/
//! Returns a random number in the interval [min, max].
/// \return int32_t
///         A number between min and max (inclusive).
/// \param   int32_t min
///         The smallest number allowed.
/// \param   int32_t max
///         The largest number allowed.
int32_t AlgorithmStub_C::get_random_int(int32_t min, int32_t max)
{
    if(max <= min)
    {
        if(max == min)
            return min;
        else
            return 0x80000000;
    }

    return (int32_t)(((uint64_t)get_random_bytes() * (uint64_t)(max - min + 1)) >> 32) + min;
}

/** virtual function  **/
/** get_random_double **/
//! Return a random 64 bit floating point value in the interval [0, 1]
/// \return double
///         A random 64 bit float.
/// \param  void
double AlgorithmStub_C::get_random_double(void)
{
    return (double)get_random_bytes() * (1./(65536.*65536.));
}


} // namespace Random
} // namespace Myth
